﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;

namespace SprintBoardMaker.Data
{
    //public class NormalizedLabel
    //{
    //    public string LabelName { get; set; }
    //}

    public class NormalizedBoard
    {
        //public List<NormalizedLabel> TrelloLabels { get; set; }
        public Dictionary<TrelloNet.Color, string> Labels { get; set; }
        public List<TrelloNet.List> TrelloLists { get; set; }
        public List<TrelloNet.Member> BoardMembers { get; set; }
        public bool Closed { get; set; }
        public string Description { get; set; }
        public string Id { get; set; }
        public string OrganizationID { get; set; }
        public string Name { get; set; }
        public TrelloNet.BoardPreferences Preferences { get; set; }

        public NormalizedBoard(TrelloNet.Board trelloNetBoard)
        {
            Closed = trelloNetBoard.Closed;
            Description = trelloNetBoard.Desc;
            Id = trelloNetBoard.Id;
            OrganizationID = trelloNetBoard.IdOrganization;
            Name = trelloNetBoard.Name;
            Preferences = trelloNetBoard.Prefs;
            Labels = trelloNetBoard.LabelNames;
            TrelloLists = MockTrelloAccess.Instance.GetListsForBoard(Id);
            BoardMembers = MockTrelloAccess.Instance.GetMembersForBoard(Id);

            #region Old Code
            //TrelloLabels = new List<NormalizedLabel>();
            //System.Drawing.Color dotNetColor;
            //System.Drawing.Brush brush;

            //foreach (var label in trelloNetBoard.LabelNames)
            //{
            //    try
            //    {
            //        dotNetColor = System.Drawing.Color.FromName(label.Key.ToString());
            //        switch (label.Key)
            //        {
            //            case TrelloNet.Color.Blue: brush = Brushes.Blue; break;
            //            case TrelloNet.Color.Green: brush = Brushes.Green; break;
            //            case TrelloNet.Color.Orange: brush = Brushes.Orange; break;
            //            case TrelloNet.Color.Purple: brush = Brushes.Purple; break;
            //            case TrelloNet.Color.Red: brush = Brushes.Red; break;
            //            case TrelloNet.Color.Yellow: brush = Brushes.Yellow; break;
            //            default: brush = Brushes.Black; break;
            //        }
            //    }
            //    catch (Exception e)
            //    {
            //        dotNetColor = System.Drawing.Color.Black;
            //        brush = System.Drawing.Brushes.Black;
            //    }

            //    TrelloLabels.Add(new NormalizedLabel() { LabelName = label.Value, LabelColor = dotNetColor });
            //}
            #endregion
        }
    }
}
